# coding: utf-8
from flask_sqlalchemy import SQLAlchemy


db = SQLAlchemy()



class CArea(db.Model):
    __tablename__ = 'c_areas'

    id = db.Column(db.String(100), primary_key=True)
    name = db.Column(db.String(255))
    parent_id = db.Column(db.String(100), index=True)



class CCmsMenu(db.Model):
    __tablename__ = 'c_cms_menu'

    id = db.Column(db.Integer, primary_key=True)
    p_id = db.Column(db.Integer)
    menu_type = db.Column(db.Integer)
    menu_name = db.Column(db.String(100))
    create_time = db.Column(db.DateTime)
    status = db.Column(db.Integer, server_default=db.FetchedValue())
    url = db.Column(db.String(100))



class CCmsRecord(db.Model):
    __tablename__ = 'c_cms_record'

    id = db.Column(db.Integer, primary_key=True)
    cms_id = db.Column(db.Integer)
    user_id = db.Column(db.String(100))
    record = db.Column(db.String(255))
    create_time = db.Column(db.DateTime)
    ip = db.Column(db.String(32))
    r_label = db.Column(db.Integer)
    r_state = db.Column(db.Integer)



class CCmsRole(db.Model):
    __tablename__ = 'c_cms_role'

    id = db.Column(db.Integer, primary_key=True)
    cms_id = db.Column(db.Integer)
    menu_id = db.Column(db.Integer)
    menu_name = db.Column(db.String(100))
    create_time = db.Column(db.DateTime)
    status = db.Column(db.Integer, server_default=db.FetchedValue())
    perms = db.Column(db.Integer)
    is_show = db.Column(db.Integer, server_default=db.FetchedValue())



class CCmsUser(db.Model):
    __tablename__ = 'c_cms_user'

    id = db.Column(db.Integer, primary_key=True)
    username = db.Column(db.String(50))
    _password = db.Column(db.String(100))
    telephone = db.Column(db.String(50), unique=True)
    create_time = db.Column(db.DateTime)
    permission = db.Column(db.Integer)
    cms_info = db.Column(db.String(32))
    logo_big = db.Column(db.String(100))
    logo_small = db.Column(db.String(100))
    power = db.Column(db.String(100))
    token = db.Column(db.String(32))
    error_num = db.Column(db.Integer)
    store_id = db.Column(db.Integer)



class CGlobalParam(db.Model):
    __tablename__ = 'c_global_params'

    id = db.Column(db.Integer, primary_key=True)
    global_params = db.Column(db.Numeric(20, 4))
    g_type = db.Column(db.Integer)
    g_name = db.Column(db.String(64))
    params_add = db.Column(db.Numeric(20, 4))



class CMallBanner(db.Model):
    __tablename__ = 'c_mall_banner'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(255))
    image_url = db.Column(db.String(255))
    link_url = db.Column(db.String(255))
    priority = db.Column(db.Integer)
    create_time = db.Column(db.DateTime)
    status = db.Column(db.Integer)
    is_show = db.Column(db.Integer)
    rich_text = db.Column(db.String(255))
    category_id = db.Column(db.Integer)
    goods_id = db.Column(db.Integer)



class CMallBuyDeal(db.Model):
    __tablename__ = 'c_mall_buy_deal'

    id = db.Column(db.Integer, primary_key=True)
    create_time = db.Column(db.DateTime)
    buy_order_id = db.Column(db.String(11), info='挂单买单id')
    sell_order_id = db.Column(db.String(11), info='挂单卖单id')
    buyer_id = db.Column(db.String(50), info='买方')
    seller_id = db.Column(db.String(50), info='卖方')
    sell_batch_id = db.Column(db.String(255), info='卖家售出商品的批次号')
    deal_type = db.Column(db.Integer, info='成交类型 1系统分配，2点对点，3协议转让')
    deal_num = db.Column(db.Integer, info='成交数量')
    deal_price = db.Column(db.Numeric(10, 2), info='成交单价，竞拍价')
    deal_money = db.Column(db.Numeric(11, 2), info='成交总金额')
    s_num = db.Column(db.Integer, info='该批次剩余数量')
    s_num_sell = db.Column(db.Integer, info='该批次剩余可卖数量')
    tn_day = db.Column(db.Integer, info='t+n')



class CMallBuyDealDeliver(db.Model):
    __tablename__ = 'c_mall_buy_deal_deliver'

    id = db.Column(db.Integer, primary_key=True)
    create_time = db.Column(db.DateTime)
    update_time = db.Column(db.DateTime)
    sell_batch_id = db.Column(db.Integer, info='发货批次id')
    num = db.Column(db.Integer, info='发货数量')
    price = db.Column(db.Numeric(10, 2), info='发货商品单价')
    total_price = db.Column(db.Numeric(10, 2), info='发货商品总价')
    logistics_name = db.Column(db.String(32, 'utf8_general_ci'))
    logistics_num = db.Column(db.String(64, 'utf8_general_ci'))
    logistics_simple = db.Column(db.String(64, 'utf8_general_ci'))
    freight = db.Column(db.Integer, server_default=db.FetchedValue(), info='运费')
    status = db.Column(db.Integer)
    sh_name = db.Column(db.String(32, 'utf8_general_ci'))
    sh_phone = db.Column(db.String(32, 'utf8_general_ci'))
    sh_province = db.Column(db.String(255, 'utf8_general_ci'))
    sh_city = db.Column(db.String(255, 'utf8_general_ci'))
    sh_district = db.Column(db.String(255, 'utf8_general_ci'))
    sh_place = db.Column(db.String(255, 'utf8_general_ci'))



class CMallBuyOrder(db.Model):
    __tablename__ = 'c_mall_buy_order'

    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.String(32), index=True)
    create_time = db.Column(db.DateTime)
    update_time = db.Column(db.DateTime)
    is_show = db.Column(db.Integer, index=True)
    status = db.Column(db.Integer, index=True, info='0挂牌中，1已成交，2手动撤销，3系统撤销')
    goods_id = db.Column(db.Integer, index=True)
    num = db.Column(db.Integer, info='数量')
    price = db.Column(db.Numeric(20, 2), info='单价')
    total_price = db.Column(db.Numeric(20, 2), info='总价')
    surplus_num = db.Column(db.Integer, info='剩余数量')
    surplus_price = db.Column(db.Numeric(20, 2), info='剩余冻结金额')
    trade_no = db.Column(db.String(32), unique=True)
    sell_batch_id = db.Column(db.String(50, 'utf8mb4_0900_ai_ci'), server_default=db.FetchedValue(), info='卖家售出批次id')
    t_type = db.Column(db.Integer, info='1挂单买入，2挂单卖出')
    reward_pool = db.Column(db.Numeric(20, 2), server_default=db.FetchedValue(), info='奖励额度')
    scan_time = db.Column(db.DateTime, info='扫描时间')
    scan_status = db.Column(db.Integer, server_default=db.FetchedValue(), info='扫描状态,0未扫描，1扫描')



class CMallBuyOrderGood(db.Model):
    __tablename__ = 'c_mall_buy_order_goods'

    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.String(32), index=True)
    order_id = db.Column(db.Integer, index=True)
    goods_id = db.Column(db.Integer, index=True)
    store_id = db.Column(db.Integer, index=True)
    create_time = db.Column(db.DateTime)
    update_time = db.Column(db.DateTime)
    end_time = db.Column(db.DateTime)
    status = db.Column(db.Integer, index=True, info='0默认1审核 2通过3失败')
    is_show = db.Column(db.Integer, index=True)
    goods_status = db.Column(db.Integer, index=True)
    back_status = db.Column(db.Integer)
    goods_name = db.Column(db.String(100))
    goods_num = db.Column(db.Integer)
    price = db.Column(db.Numeric(20, 2))
    integral = db.Column(db.Integer)
    total_price = db.Column(db.Numeric(20, 2))
    actual_price = db.Column(db.Numeric(20, 2))
    actual_one = db.Column(db.Numeric(20, 2), info='单商品实付价格')
    coupons_price = db.Column(db.Numeric(20, 2), info='优惠价格')
    freight = db.Column(db.Integer)
    goods_code = db.Column(db.String(255))
    refunds_num = db.Column(db.Integer, info='退款数量')
    refunds_price = db.Column(db.Numeric(20, 2), info='退款价格')
    logistics_num = db.Column(db.String(64))
    logistics_name = db.Column(db.String(32))
    goods_img = db.Column(db.String(255))



class CMallCoupon(db.Model):
    __tablename__ = 'c_mall_coupons'

    id = db.Column(db.Integer, primary_key=True)
    create_time = db.Column(db.DateTime)
    expiration_time = db.Column(db.Integer)
    user_id = db.Column(db.String(32), index=True)
    goods_id = db.Column(db.Integer, index=True)
    sku_id = db.Column(db.Integer, index=True)
    store_id = db.Column(db.Integer, index=True)
    status = db.Column(db.Integer, index=True)
    num = db.Column(db.Integer)
    name = db.Column(db.String(50))
    price = db.Column(db.Integer)
    coupons_img = db.Column(db.String(256))
    user_level = db.Column(db.Integer)
    discount = db.Column(db.Numeric(20, 2))
    pay_price = db.Column(db.Integer)
    minus_price = db.Column(db.Numeric(10, 2))



class CMallDelivery(db.Model):
    __tablename__ = 'c_mall_delivery'

    id = db.Column(db.Integer, primary_key=True)
    create_time = db.Column(db.DateTime)
    name = db.Column(db.String(50))
    simple = db.Column(db.String(50))



class CMallGood(db.Model):
    __tablename__ = 'c_mall_goods'

    id = db.Column(db.Integer, primary_key=True)
    create_time = db.Column(db.DateTime)
    price = db.Column(db.Numeric(20, 2))
    price_high = db.Column(db.Numeric(20, 2))
    integral = db.Column(db.Numeric(20, 2))
    depth = db.Column(db.Integer)
    old_price = db.Column(db.Numeric(20, 2))
    fees = db.Column(db.Numeric(20, 2))
    freight = db.Column(db.Integer)
    name = db.Column(db.String(255))
    goods_img = db.Column(db.String(255))
    status = db.Column(db.Integer, info='商品状态')
    is_show = db.Column(db.Integer)
    is_type = db.Column(db.Integer)
    rich_text = db.Column(db.String(1024))
    category_id = db.Column(db.Text, index=True, info='类型')
    sales = db.Column(db.Integer)
    stock_t = db.Column(db.Integer)
    stock_c = db.Column(db.Integer)
    priority = db.Column(db.Integer)
    pay_type = db.Column(db.String(10))
    user_id = db.Column(db.String(50), index=True)
    token = db.Column(db.String(100), info='商品token')
    store_id = db.Column(db.Integer)
    sku = db.Column(db.String(255))
    goods_code = db.Column(db.String(50))



class CMallGoodsBrand(db.Model):
    __tablename__ = 'c_mall_goods_brand'

    id = db.Column(db.Integer, primary_key=True)
    create_time = db.Column(db.DateTime)
    name = db.Column(db.String(50))
    city = db.Column(db.String(50))
    brand_img = db.Column(db.String(255))
    priority = db.Column(db.Integer)
    status = db.Column(db.Integer)



class CMallGoodsCategory(db.Model):
    __tablename__ = 'c_mall_goods_category'

    id = db.Column(db.Integer, primary_key=True)
    name = db.Column(db.String(50))
    create_time = db.Column(db.DateTime)
    p_path = db.Column(db.Text)
    p_id = db.Column(db.String(50))
    p_depth = db.Column(db.Integer)
    status = db.Column(db.Integer)
    is_show = db.Column(db.Integer)
    is_type = db.Column(db.Integer)
    priority = db.Column(db.Integer)
    small_img = db.Column(db.String(255))
    big_img = db.Column(db.String(255))



class CMallGoodsDetail(db.Model):
    __tablename__ = 'c_mall_goods_detail'

    id = db.Column(db.Integer, primary_key=True)
    create_time = db.Column(db.DateTime)
    name = db.Column(db.String(100))
    goods_id = db.Column(db.Integer, index=True)
    category_id = db.Column(db.Integer, index=True)
    status = db.Column(db.Integer)
    goods_img = db.Column(db.String(255))
    priority = db.Column(db.Integer)



class CMallGoodsSku(db.Model):
    __tablename__ = 'c_mall_goods_sku'

    id = db.Column(db.Integer, primary_key=True)
    create_time = db.Column(db.DateTime)
    goods_id = db.Column(db.Integer)
    sku_img = db.Column(db.String(1024))
    status = db.Column(db.Integer)
    priority = db.Column(db.Integer)
    category_id = db.Column(db.Integer)
    is_show = db.Column(db.Integer)
    name = db.Column(db.String(100))
    old_price = db.Column(db.Numeric(20, 2))
    price = db.Column(db.Numeric(20, 2))
    sales = db.Column(db.Integer)
    stock_c = db.Column(db.Integer)
    stock_t = db.Column(db.Integer)



class CMallGoodsSkuSpec(db.Model):
    __tablename__ = 'c_mall_goods_sku_spec'

    id = db.Column(db.Integer, primary_key=True)
    create_time = db.Column(db.DateTime)
    sku_id = db.Column(db.Integer)
    spec_id = db.Column(db.Integer)
    option_id = db.Column(db.Integer)



class CMallGoodsSpec(db.Model):
    __tablename__ = 'c_mall_goods_spec'

    id = db.Column(db.Integer, primary_key=True)
    create_time = db.Column(db.DateTime)
    goods_id = db.Column(db.Integer)
    name = db.Column(db.String(100))



class CMallGoodsSpecOption(db.Model):
    __tablename__ = 'c_mall_goods_spec_option'

    id = db.Column(db.Integer, primary_key=True)
    create_time = db.Column(db.DateTime)
    spec_id = db.Column(db.Integer)
    value = db.Column(db.String(100))



class CMallGoodsStore(db.Model):
    __tablename__ = 'c_mall_goods_store'

    id = db.Column(db.Integer, primary_key=True)
    create_time = db.Column(db.DateTime)
    name = db.Column(db.String(50))
    city = db.Column(db.String(50))
    store_img = db.Column(db.String(255))
    status = db.Column(db.Integer)
    priority = db.Column(db.Integer)
    sales = db.Column(db.Integer)
    sales_price = db.Column(db.Numeric(20, 2))
    income = db.Column(db.Numeric(20, 2), server_default=db.FetchedValue(), info='余额')
    income_s = db.Column(db.Numeric(20, 2), server_default=db.FetchedValue(), info='锁定余额')
    store_type = db.Column(db.Text, info='店铺分类')
    content = db.Column(db.Text, info='店铺内容')



class CMallShoppingCart(db.Model):
    __tablename__ = 'c_mall_shopping_cart'

    id = db.Column(db.Integer, primary_key=True)
    create_time = db.Column(db.DateTime)
    user_id = db.Column(db.String(32), index=True)
    goods_id = db.Column(db.Integer, index=True)
    sku_id = db.Column(db.Integer, index=True)
    store_id = db.Column(db.Integer, index=True)
    status = db.Column(db.Integer, index=True)
    num = db.Column(db.Integer)



class COrderRecharge(db.Model):
    __tablename__ = 'c_order_recharge'

    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.String(32), index=True)
    create_time = db.Column(db.DateTime)
    update_time = db.Column(db.DateTime)
    status = db.Column(db.Integer, index=True)
    price = db.Column(db.Numeric(20, 2))
    number = db.Column(db.Integer)
    trade_no = db.Column(db.String(32))
    order_img = db.Column(db.String(255))
    w_type = db.Column(db.Integer, index=True)



class COrderWithdraw(db.Model):
    __tablename__ = 'c_order_withdraw'

    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.String(32))
    create_time = db.Column(db.DateTime)
    update_time = db.Column(db.DateTime)
    status = db.Column(db.Integer)
    price = db.Column(db.Numeric(20, 3))
    income = db.Column(db.Numeric(20, 3))
    num = db.Column(db.Integer)
    trade_no = db.Column(db.String(100))
    withdraw_img = db.Column(db.String(255))
    w_type = db.Column(db.Integer)
    withdraw_date = db.Column(db.Date)
    pay_type = db.Column(db.Integer)
    to_status = db.Column(db.Integer, server_default=db.FetchedValue(), info='转换状态 1转换')



class CPayAccount(db.Model):
    __tablename__ = 'c_pay_account'

    id = db.Column(db.Integer, primary_key=True)
    create_time = db.Column(db.DateTime)
    pay_name = db.Column(db.String(255))
    pay_img = db.Column(db.String(255))
    pay_card = db.Column(db.String(50))
    real_name = db.Column(db.String(50))
    bank_name = db.Column(db.String(16))
    pay_type = db.Column(db.Integer)



class CTradeManage(db.Model):
    __tablename__ = 'c_trade_manage'

    id = db.Column(db.Integer, primary_key=True)
    start_time = db.Column(db.Time)
    end_time = db.Column(db.Time)
    trade_type = db.Column(db.Integer)
    trade_status = db.Column(db.Integer)
    trade_name = db.Column(db.String(100))



class CUser(db.Model):
    __tablename__ = 'c_user'

    id = db.Column(db.String(100), primary_key=True)
    phone = db.Column(db.String(11))
    username = db.Column(db.String(50))
    nickname = db.Column(db.String(100))
    _password = db.Column(db.String(100))
    real_name = db.Column(db.String(50))
    avatar = db.Column(db.String(256))
    create_time = db.Column(db.DateTime)
    p_id = db.Column(db.String(100), index=True)
    p_id2 = db.Column(db.String(100), index=True)
    rp_id = db.Column(db.String(100), index=True, info='实际的上级id')
    p_path = db.Column(db.Text)
    blockade = db.Column(db.Integer)
    error_num = db.Column(db.Integer)
    pay_pwd = db.Column(db.String(100))
    invite = db.Column(db.String(32))
    n_level = db.Column(db.Integer, index=True, server_default=db.FetchedValue())
    n_level_manual = db.Column(db.Integer, server_default=db.FetchedValue())
    n_level_agent = db.Column(db.Integer, server_default=db.FetchedValue())
    team_num = db.Column(db.Integer, server_default=db.FetchedValue())
    direct_num = db.Column(db.Integer, server_default=db.FetchedValue())
    direct_buy = db.Column(db.Integer, server_default=db.FetchedValue(), info='有效直推会员数量')
    token = db.Column(db.String(100), index=True)
    team_buy = db.Column(db.Integer, server_default=db.FetchedValue())
    user_buy = db.Column(db.Integer, server_default=db.FetchedValue())
    buy_num = db.Column(db.Integer, info='购买次数')
    status = db.Column(db.Integer)
    income = db.Column(db.Numeric(20, 2), server_default=db.FetchedValue())
    integral = db.Column(db.Numeric(20, 2), server_default=db.FetchedValue())
    income_r = db.Column(db.Numeric(20, 2), server_default=db.FetchedValue(), info='释放钱包')
    sign_in_date = db.Column(db.Date)
    openid = db.Column(db.String(100))
    update_time = db.Column(db.DateTime)



class CUserAddres(db.Model):
    __tablename__ = 'c_user_address'

    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.String(32), index=True)
    create_time = db.Column(db.DateTime)
    status = db.Column(db.Integer, index=True)
    name = db.Column(db.String(32))
    phone = db.Column(db.String(32))
    province = db.Column(db.String(255))
    city = db.Column(db.String(255))
    district = db.Column(db.String(255))
    place = db.Column(db.String(255))



class CUserCoupon(db.Model):
    __tablename__ = 'c_user_coupons'

    id = db.Column(db.Integer, primary_key=True)
    create_time = db.Column(db.DateTime)
    expiration_time = db.Column(db.DateTime)
    user_id = db.Column(db.String(32), index=True)
    coupons_id = db.Column(db.Integer, index=True)
    status = db.Column(db.Integer, index=True)
    num = db.Column(db.Integer)
    name = db.Column(db.String(50))
    price = db.Column(db.Integer)
    coupons_img = db.Column(db.String(256))
    discount = db.Column(db.Numeric(20, 2))
    user_level = db.Column(db.Integer)
    minus_price = db.Column(db.Numeric(10, 2))



class CUserDevice(db.Model):
    __tablename__ = 'c_user_device'

    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.String(100), nullable=False)
    device = db.Column(db.String(100))
    device_id = db.Column(db.String(100))
    device_name = db.Column(db.String(100))
    ip = db.Column(db.String(100))
    create_time = db.Column(db.DateTime)



class CUserPayAccount(db.Model):
    __tablename__ = 'c_user_pay_account'

    id = db.Column(db.Integer, primary_key=True)
    create_time = db.Column(db.DateTime)
    user_id = db.Column(db.String(100), index=True)
    pay_type = db.Column(db.Integer)
    pay_name = db.Column(db.String(255))
    pay_img = db.Column(db.String(255))
    pay_card = db.Column(db.String(50))
    real_name = db.Column(db.String(50))



class CUserRecord(db.Model):
    __tablename__ = 'c_user_record'
    __table_args__ = (
        db.Index('user_id_r_label', 'user_id', 'r_label'),
    )

    id = db.Column(db.Integer, primary_key=True)
    create_time = db.Column(db.DateTime)
    user_id = db.Column(db.String(100), index=True)
    other_id = db.Column(db.String(100), index=True)
    num = db.Column(db.Numeric(20, 2))
    r_state = db.Column(db.Integer)
    r_label = db.Column(db.Integer, index=True)
    r_type = db.Column(db.Integer)
    r_coin = db.Column(db.Numeric(20, 2))
    r_wallet = db.Column(db.Integer)
    status = db.Column(db.Integer)
    order_id = db.Column(db.String(100))



class JReward(db.Model):
    __tablename__ = 'j_reward'

    id = db.Column(db.Integer, primary_key=True)
    order_id = db.Column(db.Integer)
    order_money = db.Column(db.String(255))
    create_time = db.Column(db.DateTime)
    create_date = db.Column(db.Date)
    fromU = db.Column(db.String(50))
    toU = db.Column(db.String(50))
    toUlv = db.Column(db.Integer)
    layer = db.Column(db.Integer)
    num = db.Column(db.Numeric(11, 2))
    fire_num = db.Column(db.Numeric(11, 2))
    t_type = db.Column(db.Integer, server_default=db.FetchedValue(), info='1为释放，2为直推，3为团队')
    r_type = db.Column(db.Integer, server_default=db.FetchedValue(), info='1为正常，2为平级奖励')



class SArticle(db.Model):
    __tablename__ = 's_article'

    id = db.Column(db.Integer, primary_key=True)
    user_id = db.Column(db.String(50))
    type_id = db.Column(db.Integer)
    create_time = db.Column(db.DateTime)
    update_time = db.Column(db.DateTime)
    title = db.Column(db.String(1024))
    content = db.Column(db.Text)
    status = db.Column(db.Integer)
    priority = db.Column(db.Integer)
    article_img = db.Column(db.String(1024), info='图片')
    author = db.Column(db.String(255))
    works = db.Column(db.String(2048))
    article_time = db.Column(db.Date)
